//
//  M80AttributedLabel+JYKit.m
//  TestNIMSDK
//
//  Created by jianyong.wang on 2017/6/2.
//  Copyright © 2017年 jianyong.wang. All rights reserved.
//

#import "M80AttributedLabel+JYKit.h"
#import "JYInputEmoticomParser.h"
#import "JYEmojiManager.h"
@implementation M80AttributedLabel (JYKit)
-(void)jy_setText:(NSString *)text
{
    self.text = @"";
    NSArray * tokens = [[JYInputEmoticomParser currentParaser]tokens:text];
    for (JYInputTextToken * token in tokens) {
        Emoticon * emoticon = [[JYEmojiManager sharedManager]emoticonByTag:token.text];
        UIImage * image = [UIImage imageNamed:emoticon.filename];
        if (image) {
            [self appendImage:image maxSize:CGSizeMake(18, 18)];
        }else{
            NSString * text = token.text;
            [self appendText:text];
        }
    }
}
@end
